package com.study.controller.FDcontroller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.study.model.jdao.FDjdao.FinanceDao;
import com.study.model.jdao.PSIjdao.PurchaseOrderDao;
import com.study.model.mdao.FDmdao.FinanceMapper;
import com.study.model.pojo.FDpojo.Finance;
import com.study.model.pojo.PSIpojo.PurchaseOrder;
import com.study.service.FDservice.FinanceServices;



@RestController
public class FinanceController {
	@Autowired
	FinanceServices fs;
	@Autowired
	FinanceDao fd;
	@Autowired
	FinanceMapper fm;
	@Autowired
	PurchaseOrderDao pd;
	
	
	/**
	  *  获取所有财务信息
	 * @return
	 */
	//访问地址：http://localhost:8089/all_pd
	@GetMapping("/all_pd")
	@ResponseBody  //将List集合以JSON数组的形式返回，页面不跳转
	public List<PurchaseOrder> allPurchaseOrder(){
		System.out.println("123444");
		return (List<PurchaseOrder>) pd.findAll();
	}
	
	/**
	  *  获取所有财务信息
	 * @return
	 */
	//访问地址：http://localhost:8089/all_Finance
	@GetMapping("/all_Finance")
	@ResponseBody  //将List集合以JSON数组的形式返回，页面不跳转
	public List<Finance> allFinance(){
		System.out.println("123444");
		return (List<Finance>) fd.findAll();
	}	


	
	/**
	 * mybatis查询
	 * @return
	 */
	@ResponseBody
	@GetMapping("all_month")
	public String  selectFinancess(){
		
		return JSON.toJSONString(fs.selectFinancess());	
	}
	
	
	/**
	 * mybatis查询周总额
	 * @return
	 */
	@ResponseBody
	@GetMapping("week_financesum")
	public String  selectFinanceSum(){		
		return JSON.toJSONString(fs.SelectFinanceSum());	
	}
	/**
	 * mybatis财务近7天财务额度
	 * @return
	 */
	@GetMapping("fianceSum7")
	@ResponseBody
	public String selectFinanceSum7() {
		return JSON.toJSONString(fs.SelectFinanceSum7());
	}
	
	/**
	 * 查询当天的财政情况
	 * @return
	 */
	@RequestMapping("thedaymsg")
	@ResponseBody
	public String changefinancestate(String thedate) {
		System.out.println("获取到的时间："+thedate);
		return  JSON.toJSONString(fs.SelectFinanceTheDay(thedate));
	}
}